<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import siteInfo from '@/api/site/siteInfo'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()



const switchStatus = (statusValue, id, statusName) => {
  siteInfo.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'site_info',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'site_id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: siteInfo.getList,
  recycleApi: siteInfo.getRecycleList,
  add: {
    show: true,
    api: siteInfo.save,
    auth: ['site:info:save']
  },
  edit: {
    show: true,
    api: siteInfo.update,
    auth: ['site:info:update']
  },
  delete: {
    show: true,
    api: siteInfo.deletes,
    auth: ['site:info:delete'],
    realApi: siteInfo.realDeletes,
    realAuth: ['site:info:realDeletes']
  },
  recovery: {
    show: true,
    api: siteInfo.recoverys,
    auth: ['site:info:recovery']
  }
})

const columns = reactive([
  {
    title: "租户ID",
    dataIndex: "site_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入租户ID"
    }
  },
  {
    title: "站点标识",
    dataIndex: "uuid",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入站点标识"
    }
  },
  {
    title: "代理商标识",
    dataIndex: "app_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入代理商标识"
    }
  },
  {
    title: "代理商租户标识",
    dataIndex: "custom_tag",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入代理商租户标识"
    }
  },
  {
    title: "租户状态",
    dataIndex: "status",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入租户状态"
    }
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入创建时间"
    },
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入更新时间"
    },
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  }
])
</script>
<script> export default { name: 'site:info' } </script>